<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/4/13
 * Time: 下午7:07
 */
class ItemService extends Service
{
    public static function tmp(){
        $cacheKey = "Dict-Item";
        $result = array();
        if(empty($result)){
            $api = new ApiService();
            $tmp = $api->getItem();

            if($tmp['state']){
                $result = $tmp['data'];
                Yii::app()->memCache->set($cacheKey, $result, 60);
            }else{
                $result = array();
            }
        }

        return $result;

    }

    public static function getItemType(){
        $list = ItemService::tmp();
        return isset($list['desc']) ? $list['desc'] : array();
    }

    public static function getItem($type){
        $list = ItemService::tmp();

        return isset($list['data'][$type]) ? $list['data'][$type] : array();
    }

}